package com.zsrt.java.day20161227.zzm.demo2;

import java.util.Random;
import java.util.Scanner;

public class FuLiCaiPiao {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			System.out.println("杜绝赌博,建设美好家园(中奖概率为1/1000).....");
			System.out.println("是否继续，是/否  (y/n)");
			String temp1 = sc.next();
			if(temp1.equals("y")){
				System.out.println("程序已经退出.....");
				break;
			}
			System.out.println("请输入一个000-999的数:");
			String num = sc.next();
			System.out.println(getNum(num));
			System.out.println("继续请按c,退出请按y");
			String temp = sc.next();
			if(temp.equals("y")){
				System.out.println("程序已经退出.....");
				break;
			}
		}
		sc.close();
	}
	public static String getNum(String num){
		Random r = new Random();
		int ran =r.nextInt(1000);
		String temp ="";
		if(ran==0){
			temp = "000";
		}else if(ran/10==0){
			temp ="00"+ran;
		}else if(ran/10>0&&ran/10<10){
			temp = "0"+ran;
		}else{
			temp =String.valueOf(ran);
		}
	
		if(num.equals(temp)){
			return "恭喜您,您从中了千分之一的奖了,真厉害，奖金1毛钱......";
		}else{
			return "很遗憾,您没中奖 ";
		}
		
	}
}
